const fs = require('fs');
const path = require('path');
const { apiPre } = require('./config');
const filePath = path.resolve(__dirname, './json/menu.json');
module.exports = (app, server, compiler) => {
  const modulePre = `${apiPre}/menu`;

  app.get(`${modulePre}/list`, (req, res) => {
    fs.readFile(filePath, (err, data) => {
      if (err) {
        res.status(503).send('数据读取错误');
        return;
      }
      res.json({
        code: 200,
        data: !data ? [] : JSON.parse(data),
      })
    })
  })
}